import Vue from 'vue'
import App from './App.vue'
import router from './router'
import '@/utils/vant-ui'
import { getToken } from '@/utils/storage'
import ArticleItem from './components/ArticleItem.vue'

Vue.component('ArticleItem', ArticleItem)

Vue.config.productionTip = false

const whiteList = ['/login']
router.beforeEach((to, from, next) => {
  const token = getToken()
  if (token) {
    next()
  } else {
    console.log(to, whiteList)
    if (whiteList.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  }
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
